package Dedup;

import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class DedupDriver {
    public static void main(String[] args)throws IOException, ClassNotFoundException, InterruptedException {
        args = new String[]{"C:\\Users\\lenovo\\IdeaProjects\\HadoopDemo\\input", "C:\\Users\\lenovo\\IdeaProjects\\HadoopDemo\\output"};
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);
        job.setJarByClass(DedupDriver.class);
        //设置Map、Combine和Reduce处理类
        job.setMapperClass(DedupMapper.class);
        job.setReducerClass(DedupReducer.class);
        //设置输出类型
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);
        //设置输入和输出目录
        FileInputFormat.addInputPath(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[1]));
        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }
}
